/**
 * Copyright (c) 2016-2021, Bosco.Liao (bosco_liao@126.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.iherus.shiro.redis.spring.boot.autoconfigure;

import org.iherus.shiro.cache.redis.connection.spring.CompatibleRedisConnectionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;

/**
 *
 * @author Bosco.Liao
 * @since 2.0.0
 */
@Configuration
@ConditionalOnClass(RedisConnectionFactory.class)
public class CompatibleRedisConnectionFactoryConfiguration {

    @Bean(name = "x_compatibleConnectionFactory")
    @ConditionalOnMissingBean(org.iherus.shiro.cache.redis.connection.RedisConnectionFactory.class)
    public CompatibleRedisConnectionFactory connectionFactory(RedisConnectionFactory redisConnectionFactory) {
        return new CompatibleRedisConnectionFactory(redisConnectionFactory);
    }

}
